package _021_11_20

//子串的数量是2的几次幂的增长   内存太大崩了
func _maxProfit(prices []int) int {
	ret := make([][]int, 0)
	temp := make([]int, 0)
	ret = append(ret, temp)

	for i := 0; i < len(prices); i++ {
		size := len(ret)
		for j := 0; j < size; j++ {
			data := make([]int, 0)
			for k := 0; k < len(ret[j]); k++ {
				data = append(data, ret[j][k])
			}
			data = append(data, prices[i])
		}
	}
	maxFit := 0
	for i := 0; i < len(ret); i++ {
		if len(ret[i]) > 1 && ret[i][len(ret[i])-1]-ret[i][0] > maxFit {
			maxFit = ret[i][len(ret[i])-1] - ret[i][0]
		}
	}
	return maxFit
}
